package collection.set;

import java.util.Comparator;
import java.util.Set;
import java.util.TreeSet;

public class TreeSetSample {
    public static void main(String[] args) {

        class IntegerComparator implements Comparator<Integer> {

            @Override
            public int compare(Integer o1, Integer o2) {
                return o2 - o1;
            }
        }

        Set<Integer> set = new TreeSet<Integer>(new IntegerComparator());
        set.add(100);
        set.add(50);
        set.add(10);
        set.add(180);
        System.out.println(set);
        // Output: [180, 100, 50, 10]
    }
}
